#pragma once

class CMemIO : public ISequentialStream
{
    CMemIO(const CMemIO&);
    CMemIO& operator=(const CMemIO&);
    
public:

    CMemIO(BYTE*, ULONG);
    virtual ~CMemIO();
    
    HRESULT STDMETHODCALLTYPE QueryInterface(const IID&, void**);
    ULONG STDMETHODCALLTYPE AddRef();
    ULONG STDMETHODCALLTYPE Release();

    HRESULT STDMETHODCALLTYPE Read(void*, ULONG, ULONG*);    
    HRESULT STDMETHODCALLTYPE Write(const void*, ULONG cb, ULONG*);
    
    ULONG GetPosition() const;
    
private:

    BYTE* const m_buf;
    const ULONG m_len;
    ULONG m_pos;
    
};
